@namespace DaoHang.Components.Pages.AIRecommendation
@using DaoHang.Models

<div class="recommendation-settings">
    <div class="settings-card">
        <div class="settings-header">
            <h5 class="settings-title">
                <i class="bi bi-gear me-2"></i>推荐设置
            </h5>
        </div>
        <div class="settings-content">
            <div class="row align-items-center">
                <div class="col-md-6">
                    <div class="preference-option">
                        <div class="form-check form-switch">
                            <input class="form-check-input" type="checkbox" id="preferChineseWebsites" 
                                   @bind="PreferChineseWebsites" @bind:after="OnPreferenceChanged" />
                            <label class="form-check-label" for="preferChineseWebsites">
                                <i class="bi bi-geo-alt-fill me-2 text-danger"></i>
                                <strong>优先推荐中国网站</strong>
                            </label>
                        </div>
                        <small class="text-muted ms-4">
                            @if (PreferChineseWebsites)
                            {
                                <span>将优先推荐中国的网站，如果不足再补充国外优质网站</span>
                            }
                            else
                            {
                                <span>推荐国际知名网站，包括中国和国外的优质网站</span>
                            }
                        </small>
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="recommendation-count">
                        <label class="form-label">推荐数量</label>
                        <select class="form-select" @bind="RecommendationCount" @bind:after="OnCountChanged">
                            <option value="10">10个网站</option>
                            <option value="15">15个网站</option>
                            <option value="20">20个网站</option>
                            <option value="25">25个网站</option>
                            <option value="30">30个网站</option>
                        </select>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

@code {
    /// <summary>
    /// 是否优先推荐中国网站
    /// </summary>
    [Parameter]
    public bool PreferChineseWebsites { get; set; } = true;

    /// <summary>
    /// 推荐数量
    /// </summary>
    [Parameter]
    public int RecommendationCount { get; set; } = 15;

    /// <summary>
    /// 偏好设置改变事件
    /// </summary>
    [Parameter]
    public EventCallback<bool> OnPreferenceChangeCallback { get; set; }

    /// <summary>
    /// 推荐数量改变事件
    /// </summary>
    [Parameter]
    public EventCallback<int> OnCountChangeCallback { get; set; }

    /// <summary>
    /// 处理偏好设置改变
    /// </summary>
    private async Task OnPreferenceChanged()
    {
        await OnPreferenceChangeCallback.InvokeAsync(PreferChineseWebsites);
    }

    /// <summary>
    /// 处理推荐数量改变
    /// </summary>
    private async Task OnCountChanged()
    {
        await OnCountChangeCallback.InvokeAsync(RecommendationCount);
    }
} 